package com.frank.auth.domain.service.impl;

import com.frank.auth.domain.bo.AuthRoleBo;
import com.frank.auth.domain.convert.AuthRoleBoConvert;
import com.frank.auth.domain.service.RoleDomainService;
import com.frank.auth.infra.basic.entity.AuthRole;
import com.frank.auth.infra.basic.service.AuthRoleService;
import org.springframework.stereotype.Service;

/**
 * @author Frank Zou
 * @version v0.0.1
 * @date 2024/2/13
 * @description
 */
@Service
public class RoleDomainServiceImpl implements RoleDomainService {

    private final AuthRoleService authRoleService;


    public RoleDomainServiceImpl(AuthRoleService authRoleService) {
        this.authRoleService = authRoleService;
    }

    @Override
    public Boolean addRole(AuthRoleBo authRoleBo) {
        AuthRole authRole = AuthRoleBoConvert.INSTANCE.convertBoToEntity(authRoleBo);
        return authRoleService.save(authRole);
    }

    @Override
    public Boolean updateRole(AuthRoleBo authRoleBo) {
        AuthRole authRole = AuthRoleBoConvert.INSTANCE.convertBoToEntity(authRoleBo);
        return authRoleService.updateById(authRole);
    }

    @Override
    public Boolean deleteRole(Long roleId) {
        return authRoleService.removeById(roleId);
    }
}
